/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package UTGBusiness;

import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Ray
 */
public class Validator {

    private IDDManager idman;
    private TDManager tdman;

    public Validator(IDDManager idman, TDManager tdman) {
        this.idman = idman;
        this.tdman = tdman;
    }

    protected boolean checkOfferIDValid(String id) {
        return idman.hasID(id);
    }

    protected boolean checkTimeValid(int time) {
        if (time < 1 || time > 24) {
            return false;
        }
        return true;
    }

    protected boolean checkTimeExceed(String seq) {
        return tdman.hasTimeExceeded(seq);
    }

    protected boolean checkTraderIDValid(String id) {
        return idman.hasID(id);
    }

    //could add more tests
    protected boolean checkShareCount(int count) {
        boolean valid = true;
        if (count == 0) {
            valid = false;
        }
        return valid;
    }

    protected boolean checkAcceptorIDValid(String id) {
        return idman.hasID(id);
    }

    protected boolean checkCompletionTimeValid(long time) {
        if (time < 0) {
            return false;
        } else {
            return true;
        }
    }

    protected boolean checkDBTRNotFound(String seq) {
        try {
            return !tdman.hasEntry(seq);
        } catch (SQLException ex) {
            Logger.getLogger(UTG.class.getName()).log(Level.SEVERE, null, ex);
        }
        return true;
    }

    protected boolean checkPricePerShareValid(double price) {
        if (price < 0) {
            return false;
        } else {
            return true;
        }
    }
}
